package org.metamodelos2.modelo.conexion;

import java.net.UnknownHostException;
import java.util.Calendar;

import com.mongodb.DB;
import com.mongodb.Mongo;
import com.mongodb.MongoException;

public class ConexionMongo {

	private Mongo conexion;
	
	public ConexionMongo(){
		try {
			conexion=new Mongo("192.168.10.107",27017);
			DB db = conexion.getDB( "test" );
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} catch (MongoException e) {
			e.printStackTrace();
		}
	}
	
	public Mongo getConexion() {
		return conexion;
	}
	
	
	public void cerrarConexion(){
		conexion.close();
	}
	
	public static void main(String[] args){
		Long inicio=Calendar.getInstance().getTimeInMillis();
		ConexionMongo conex=new ConexionMongo();
		Long finConexion=Calendar.getInstance().getTimeInMillis();
		conex.cerrarConexion();
		Long finDesconexion=Calendar.getInstance().getTimeInMillis();
		System.out.println("conexion: "+(finConexion-inicio));
		System.out.println("desconexion: "+(finDesconexion-finConexion));
	}
}
